home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / The Hacks / BlueBox Spy / Blue Box Daemon / source / CTerminalPane.h < prev    next >
Encoding:
Text File  |  1998-08-06  |  3.2 KB  |  125 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    CTerminalPane.h               ©1996-1998 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4.  
  5. #pragma once
  6.  
  7. #include <LView.h>
  8. #include <LPeriodical.h>
  9.  
  10. typedef UInt32 CharIndexT;
  11.  
  12. struct TermCharT {
  13.     CharIndexT row;
  14.     CharIndexT col;
  15. };
  16.  
  17.  
  18. // ===========================================================================
  19. //        • CTerminalPane
  20. // ===========================================================================
  21. //    This class provides a rudimentary terminal emulator. It’s nothing fancy
  22. //    or snazzy. It doesn’t do VT100; it doesn’t do scrollback; it doesn’t
  23. //    handle any kind of formatting.
  24.  
  25. class CTerminalPane :    public PP_PowerPlant::LView,
  26.                         public PP_PowerPlant::LPeriodical {
  27.  
  28. public:
  29.     enum { class_ID = 'TERM' };
  30.     
  31.                             CTerminalPane(
  32.                                     PP_PowerPlant::LStream*    inStream);
  33.                             ~CTerminalPane();
  34.  
  35.     // terminal primitives
  36.  
  37.     virtual void            DoWriteChar(
  38.                                     char        inChar);
  39.     virtual void            DoWriteStr(
  40.                                     const char*    inString);
  41.     virtual void            DoWriteBfr(
  42.                                     const char*    inBuffer,
  43.                                     SInt32        inByteCount);
  44.     virtual void            DoWriteCharNum(
  45.                                     char        inChar,
  46.                                     char        inLeftBracket = 0,
  47.                                     char        inRightBracket = 0);
  48.     virtual void            DoClearScreen();
  49.  
  50.     virtual void            SetBlinking(
  51.                                     bool        inBlinkMode);
  52.     
  53.     // drawing
  54.     
  55. protected:
  56.     virtual void            DrawSelf();    
  57.         
  58.     // blinking cursor support
  59.     
  60.     virtual void            ActivateSelf();
  61.     virtual void            DeactivateSelf();
  62.     virtual void            SpendTime(
  63.                                     const EventRecord&    inMacEvent);
  64.     
  65.     // internal screen primitives
  66.     
  67.     virtual void            ClearToEOL(
  68.                                     const TermCharT&    inStartChar);
  69.     virtual void            ClearToEOS(
  70.                                     const TermCharT&    inStartChar);
  71.     virtual void            ScrollTerm();
  72.     virtual void            CursorMoved();
  73.  
  74.     virtual void            InvalChar(
  75.                                     const TermCharT&    inChar,
  76.                                     CharIndexT            inNumChars = 1);
  77.     virtual void            InvertChar(
  78.                                     const TermCharT&    inChar);
  79.  
  80.     // character-to-pixel conversions
  81.     
  82.     virtual void            FetchCharHitBy(
  83.                                     const PP_PowerPlant::SPoint32&        inImagePt,
  84.                                     TermCharT&            outChar);
  85.     virtual bool            FetchLocalCharFrame(
  86.                                     const TermCharT&    inChar,
  87.                                     Rect&                outCharFrame,
  88.                                     CharIndexT            inNumCols = 1,
  89.                                     CharIndexT            inNumRows = 1);
  90.     
  91.     // direct access to the screen buffer
  92.     
  93.     virtual void            PutCharAt(
  94.                                     const TermCharT&    inCharPosition,
  95.                                     char                inChar);
  96.     virtual char            GetCharFrom(
  97.                                     const TermCharT&    inCharPosition) const;
  98.     
  99.  
  100.     enum {
  101.         maxX = 80,                                        // width of screen
  102.         maxY = 24                                        // height of screen
  103.     };
  104.  
  105.     UInt8                    mScreenBfr[maxY][maxX];        //! TEMPORARY: contents of the screen
  106.  
  107.     CharIndexT                mRows;                        // size of table
  108.     CharIndexT                mCols;
  109.     SInt32                    mRowHeight;                    // size of character grid
  110.     SInt32                    mColWidth;
  111.  
  112.     TermCharT                mCurrentCursor;                // position of character cursor
  113.     TermCharT                mPreviousCursor;            // previous position of cursor
  114.     SInt16                    mCharsToInvalLine;            // used for optimization to invalidate entire line at once
  115.     
  116.     bool                    mBlinkCursor;                // cursor blinking is enabled
  117.     bool                    mCursorBlinkVisible;        // cursor is inverted
  118.     SInt32                    mCursorBlinkTick;            // time at last cursor flash
  119.  
  120.  
  121. private:
  122.     void                    InitTerm();
  123.  
  124. };
  125.